

<?php

	/*
	*
	* @header pname 
	*/

	require_once("connect_to_database.php");
	
	$project_name = mysql_real_escape_string($_POST['project']);
	$username = mysql_real_escape_string($_POST['username']);
	$message = mysql_real_escape_string($_POST['message']);
	
	/*Get the color from the 'members' table the user was assigned when logged in*/
	$sql = mysql_query("SELECT color FROM members WHERE username = '".$username."'");
	$color = mysql_fetch_array($sql);

	//chat tables are named in the form name_chat
	$query = ("INSERT INTO `".$project_name."_chat` (username, message, color) values ('".$username."','".$message."','".$color['color']."')");

	echo $query;
	$result = mysql_query($query);

	if(!$result)
		die(mysql_error());
	echo("Success!");

?>
